﻿#ifndef DINGDANDETAIL_H
#define DINGDANDETAIL_H

#include <QObject>
#include "product.h"

class DingdanDetail : public QObject
{
    Q_OBJECT
public:
    explicit DingdanDetail(QObject *parent = nullptr);

    DingdanDetail(QJsonObject obj);

    int id;
    QString username;
    QString dingdanId;
    QString productId;
    int count;
    double price;
    double ticketIn;
    double ticketOut;
    double moneyIn;
    double moneyOut;
    double profit;
    double financeMake;         //财务操作金额

    void loadFromJsonObject(QJsonObject obj);

    QString toJson();

    static QString toJson(QList<DingdanDetail*> details){
        QString jsonStr = "[";

        for(DingdanDetail *detail:details){
            jsonStr.append(detail->toJson()+",");
        }

        jsonStr.append("]");

        return jsonStr;
    }

    Product* getProduct();

signals:

public slots:

private:
    Product *product;
};

#endif // DINGDANDETAIL_H
